//
//  XHSearchBar.m
//  新浪微博
//
//  Created by mac on 14-10-28.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "XHSearchBar.h"
#import "UIImage+XH.h"
#import "UIView+XH.h"

@implementation XHSearchBar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        self.background = [UIImage resizableImageWithName:@"searchbar_textfield_background"];
    
    //文本居中
        self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        
        //设置清除按钮
        self.clearButtonMode = UITextFieldViewModeWhileEditing;
        
        //放大镜
        //创建uiview的同时初始化image，那么UIImageView的frame就是image的size
        
        UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageWithName:@"searchbar_textfield_search_icon"]];
        //设置放大镜为leftview
        self.leftView = iv;
        self.leftViewMode = UITextFieldViewModeAlways;
        iv.width = 40;
        iv.contentMode = UIViewContentModeCenter;
        
        //默认提示信息
        self.placeholder = @"输入搜索地点/地铁站/小区";
        self.font = [UIFont systemFontOfSize:13];
    
    }
    return self;
}



@end
